package com.ruoyi.business.controller;

import com.ruoyi.business.domain.DangerGoodsPur;
import com.ruoyi.business.service.IDangerGoodsPurService;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 危险品采购记录Controller
 * 
 * @author qiancheng
 * @date 2025-06-13
 */
@Api(tags = "危险品采购记录管理")
@RestController
@RequestMapping("/business/pur")
public class DangerGoodsPurController extends BaseController
{
    @Autowired
    private IDangerGoodsPurService dangerGoodsPurService;

    /**
     * 安全管理->>危险品管理->>查询危险品采购记录列表
     */
    @ApiOperation("查询危险品采购记录列表")
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(DangerGoodsPur dangerGoodsPur)
    {
        startPage();
        List<DangerGoodsPur> list = dangerGoodsPurService.selectDangerGoodsPurList(dangerGoodsPur);
        return getDataTable(list);
    }

    /**
     * 导出危险品采购记录列表
     */
    @ApiOperation("导出危险品采购记录列表")
    @PreAuthorize("@ss.hasPermi('business:pur:export')")
    @Log(title = "危险品采购记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DangerGoodsPur dangerGoodsPur)
    {
        List<DangerGoodsPur> list = dangerGoodsPurService.selectDangerGoodsPurList(dangerGoodsPur);
        ExcelUtil<DangerGoodsPur> util = new ExcelUtil<DangerGoodsPur>(DangerGoodsPur.class);
        util.exportExcel(response, list, "危险品采购记录数据");
    }

    /**
     * 获取危险品采购记录详细信息
     */
    @ApiOperation("获取危险品采购记录详细信息")
    @PreAuthorize("@ss.hasPermi('business:pur:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@ApiParam("采购记录ID") @PathVariable("id") Long id)
    {
        return success(dangerGoodsPurService.selectDangerGoodsPurById(id));
    }

    /**
     * 安全管理->>危险品管理->>新增危险品采购记录
     */
    @ApiOperation("新增危险品采购记录")
    @Anonymous
    @PostMapping
    public AjaxResult add(@ApiParam("危险品采购记录信息") @RequestBody DangerGoodsPur dangerGoodsPur)
    {
        return toAjax(dangerGoodsPurService.insertDangerGoodsPur(dangerGoodsPur));
    }

    /**
     * 安全管理->>危险品管理->>修改危险品采购记录
     */
    @ApiOperation("修改危险品采购记录")
    @Anonymous
    @PutMapping
    public AjaxResult edit(@ApiParam("危险品采购记录信息") @RequestBody DangerGoodsPur dangerGoodsPur)
    {
        return toAjax(dangerGoodsPurService.updateDangerGoodsPur(dangerGoodsPur));
    }

    /**
     * 安全管理->>危险品管理->>删除危险品采购记录
     */
    @ApiOperation("删除危险品采购记录")
    @Anonymous
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@ApiParam("采购记录ID数组") @PathVariable Long[] ids)
    {
        return toAjax(dangerGoodsPurService.deleteDangerGoodsPurByIds(ids));
    }
}
